package com.sduept.nwld.wave.rest;

import com.sduept.cim.wave.service.DmfCreateManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;


/**
 * 故障简报REST服务
 * @author Ningfw
 * @date 2017-06-23
 *
 */
@RestController
@RequestMapping("/wavetest/")
public class WaveTestRest {

	@Autowired
	DmfCreateManager manager ;
	

	@GetMapping("/t/{params}")
	public String createDmf(@PathVariable("params") String params){
		manager.createDmf(params);
		
		return params;
	}
	
	

	@GetMapping("/getWaveData")
	public String getReport(){
		StringBuilder rtn = new StringBuilder();
		try {
			RandomAccessFile raf = new RandomAccessFile("e:/8444249526173698.txt","r");
			String ln = raf.readLine();
			while(ln != null){
				rtn.append(ln);
				ln = raf.readLine();
			}
			raf.close();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return rtn.toString();
	}
	
}
